package com.uw.uwconfig.client.util;

import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;

public class FieldUtil {
    private FieldUtil() {
    }


    public static List<Field> getAnnotationFieldList(Class<?> beanClass, Class<? extends Annotation> annotationClass) {
        List<Field> result = new ArrayList<>();
        while (beanClass != null) {
            Field[] declaredFields = beanClass.getDeclaredFields();
            for (Field declaredField : declaredFields) {
                if (declaredField.isAnnotationPresent(annotationClass)) {
                    result.add(declaredField);
                }
            }

            beanClass = beanClass.getSuperclass();
        }
        return result;
    }
}
